<%--
    Document   : newarea
    Created on : Oct 16, 2011, 10:43:32 PM
    Author     : VIC
--%>
<%--
    Tham số hệ thống
newarea  areainfo   areaname   areamsg  save
order    status     action  search
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@page import="java.util.*,Beans.ThamSoHT, Beans.KhuVuc,Models.ThamSoHT_Model,Models.Ban_Model, Models.KhuVuc_Model"%>
<!--
Danh sách các tham số hệ thống ở trang này :
order      areainfo     areamsg     status      arealang
newarea    areaname     save        action      arealist
enable     disable      search
-->
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'msgservice', 'checksubmitmsg', 'areaname', 'notice', 'rightmsg', 'save','order','status','tablelist','enable','disable','table', 'tableinfo', 'tablename', 'numbertable', 'numberseat', 'all', 'numberofseat'  "; // chuỗi chứa các mã tham số của trang này.
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();
            String areaname = mdsts[1].getTenTS();
            String checksubmitmsg = mdsts[2].getTenTS();
            String disable = mdsts[3].getTenTS();
            String enable = mdsts[4].getTenTS();
            String msgservice = mdsts[5].getTenTS();
            String notice = mdsts[6].getTenTS();
            String numberofseat = mdsts[7].getTenTS();
            String numberseat = mdsts[8].getTenTS();
            String numbertable = mdsts[9].getTenTS();
            String order = mdsts[10].getTenTS();
            String rightmsg = mdsts[11].getTenTS();
            String save = mdsts[12].getTenTS();
            String status = mdsts[13].getTenTS();
            String table = mdsts[14].getTenTS();
            String tableinfo = mdsts[15].getTenTS();
            String tablelist = mdsts[16].getTenTS();
            String tablename = mdsts[17].getTenTS();

            String msgright = notice + "/" + rightmsg;
            String msgchecksubmit = notice + "/" + checksubmitmsg;
            String servicemsg = notice + "/" + msgservice;
            Vector vBan = (Vector) request.getAttribute("DSBan");
            Vector vKV = (Vector) request.getAttribute("DSKV");
            int numpage = 0;// khởi tạo số trang = 0
            int vsize = vBan.size();
            if (vsize % 6 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 6;
            } else {
                numpage = vsize / 6 + 1;
            }
            String xx = (String) request.getAttribute("item"); 
            int item = Integer.parseInt(xx);
            String xx1 = (String) request.getAttribute("item");
            int item1 = Integer.parseInt(xx1);
            Vector v = (Vector) request.getAttribute("DSMapBan");
            String makv = (String) request.getAttribute("makv");
            int numpage1 = 0;// khởi tạo số trang = 0
            int vsize1 = v.size();
            if (vsize1 % 30 == 0) // mỗi trang có 6 dòng
            {
                numpage1 = vsize1 / 30;
            } else {
                numpage1 = vsize1 / 30 + 1;
            }
%>
<h1><img style=" margin-top: 7px; margin-right: 13px; opacity: 0.8;" alt="" src="../images/table11.png"><%=table%></h1>
<div class="cb"></div>
<div class="bloc left">
    <div class="title"><%=tableinfo%></div>
        <div class="content" style=" padding-top: 25px; padding-bottom: 15px;">
        <form name="addTable" action="">           
            <div style="width: 90px; float: left; margin-left: 10px;"><%=areaname%></div>
            <select name="tenkv" class="1" lang="<%=msgright%>" onchange="ShowMap(this.value, this.className, this.lang)">
                <%
                            for (int k = 0; k < vKV.size(); k++) {
                                Beans.KhuVuc kvv = (Beans.KhuVuc) vKV.elementAt(k);
                %>
                <option value="<%=kvv.getMaKV()%>"><%=kvv.getTenKV()%></option>
                <%  }
                %>
            </select><br />
            <input style="margin-left: 100px; margin-top: 20px;" class="button" lang="<%=msgright%>" alt="<%=msgchecksubmit%>" onclick="CreateTable(this.lang, this.alt);" type="button" value="<%=save%>" />
            <div class="banghe" >
                <table style="width: 180px;">
                    <tr>
                        <td style=" width: 80px; background: none; border: none;"><center><%=numbertable%></center></td>
                        <td style=" width: 80px; background: none; border: none;"><center><%=numberseat%></center></td>
                    </tr>
                    <tr>
                        <td style="  background: none; border: none;"><center><input type="text" class="text" style="width: 60px;" maxlength="3" size="5" name="ban" onkeypress="return keypress(event)"></center></td>
                        <td style="  background: none; border: none;"><center><input type="text" class="text" style="width: 60px;" maxlength="3" size="5" name="ghe" onkeypress="return keypress(event)"></center></td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
</div>
<div id="DSBan" class="bloc right" style=" min-height: 164px;">    
    <div class="title">
        <%=tablelist%>        
    </div>
    <div class="content">
        <form name="dsban" action="">
            <table class="mytable" border="0" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <th style=" width: 12%;"><%=order%></th>
                        <th style=" width: 27%;">
                            <a href="#" id="titledskv1" style="margin-top: 5px;" class="down"  name="1" lang="<%=msgright%>" onclick="BanSortTenKV( this.className, this.name, this.lang)">
                                <div style="float:left"><%=areaname%></div>
                                <div id="sortkv1" class="down1"></div>
                            </a>
                        </th>
                        <th style=" width: 15%;"><%=tablename%></th>
                        <th style=" width: 15%;"><%=numberofseat%></th>
                        <th style="margin-top: 2px;">
                            <a href="#" id="titledskv2" class="down"  name="1" lang="<%=msgright%>" onclick="BanSortTTKV( this.className, this.name, this.lang)">
                                <div><%=status%></div>
                                <div >
                                    <div id="sortkv2" class="down2"></div>
                                    <div id="sortkv2" class="up2" style="display:none;"></div>
                                </div>
                            </a>
                        </th>
                    </tr>
                    <tr id="searchTenKV" >
                        <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" alt="1" src="../images/search1.png" lang="<%=msgright%>" onclick="SearchBan(this.alt, this.lang)"></th>
                        <th >
                            <input type="textbox" style="width: 95px;"  name="TENKV" class="tenkv text" alt="1" size="13" lang="<%=msgright%>" >
                        </th>
                        <th><input type="textbox" style="width: 50px;" name="TENBAN" maxlength="3" alt="1" class="tenban text" size="4" lang="<%=msgright%>"  onkeypress="return keypress(event)"></th>
                        <th><input type="textbox" style="width: 50px;" name="SOGHE" maxlength="3" alt="1" class="soghe text" size="4" lang="<%=msgright%>" onkeypress="return keypress(event)"></th>
                        <th>
                            <select class="select" name="TINHTRANG" id="1" lang="<%=msgright%>" onchange="SearchBan(this.id, this.lang)">
                                <option value="all"><%= all%></option>
                                <option value="1"><%=enable%></option>
                                <option value="0"><%=disable%></option>
                            </select>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <%
                                for (int i = (item - 1) * 6; i < (item - 1) * 6 + 6 && i < vsize; i++) {
                                    Beans.Ban b = (Beans.Ban) vBan.elementAt(i);
                    %>
                    <tr>
                        <td class="STT"><%= i + 1%></td>
                        <td>
                            <select onchange="UpdateKVBan(this.value, this.id, this.lang)" id="<%=b.getMaBan() %>" lang="<%=msgright%>">
                                <option value="<%=b.getMaKV()%>"><%=Ban_Model.LayTenKV(b.getMaKV(), langid)%></option>
                                <%
                                    KhuVuc[] dskv = KhuVuc_Model.DSKhuVuc(b.getMaKV(), langid);
                                    for (int j = 0; j < dskv.length; j++) {%>
                                        <option value="<%=dskv[j].getMaKV() %>"><%=dskv[j].getTenKV() %></option>
                                <%  }%>
                            </select>
                        </td>
                        <td style=" padding-left: 15px;"><%=b.getTenBan()%></td>
                        <td style=" padding-left: 15px;"><%=b.getSoGhe()%></td>
                        <td>
                            <select  class="<%= b.getMaBan()%>" lang="<%=msgright%>" name="<%=b.getMaTTBan() %>" id="<%=servicemsg%>" onchange="UpdateStatusBan(this.value,  this.className, this.lang, this.name, this.id)">
                                <%
                                                            if (b.getTinhTrang() == 1) {%>
                                <option value="1"><%= enable%></option>
                                <option value="0"><%= disable%></option>
                                <%  } else {%>
                                <option value="0"><%= disable%></option>
                                <option value="1"><%= enable%></option>
                                <%  }
                                %>
                            </select>
                        </td>
                    </tr>
                    <%  }
                    %>
                </tbody>
            </table>
            <div class="pagination">
                <%
                            
                            int trang = 1;
                            if (item > 1) {
                                trang = item - 1;
                            }
                %>
                <%          if (vsize > 10) {%>
                <a href="#" class="prev" lang="<%=msgright%>" name="<%= trang%>" onclick="NewTable(this.name, this.lang)">«</a>
                <%
                              for (int c = 1; c <= numpage; c++) {
                                  if (numpage < 10) {
                                      if (c != item) {%>
                <a href="#" lang="<%=msgright%>"  name="<%= c%>" onclick="NewTable(this.name, this.lang)" ><%= c%></a>
                <%                } else {%>
                <a class="current"> <%= c%></a>
                <%                }
                                                } else {
                                                    if (c == item && item == 1) {%>
                <a href="#" lang="<%=msgright%>" class="current"   name="<%= item%>" onclick="NewTable(this.name, this.lang)"><%= item%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item + 1%>" onclick="NewTable(this.name, this.lang)"><%= item + 1%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item + 2%>" onclick="NewTable(this.name, this.lang)"><%= item + 2%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item + 3%>" onclick="NewTable(this.name, this.lang)"><%= item + 3%></a>
                ...
                <a href="#" lang="<%=msgright%>"   name="<%= numpage - 3%>" onclick="NewTable(this.name, this.lang)"><%= numpage - 3%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= numpage - 2%>" onclick="NewTable(this.name, this.lang)"><%= numpage - 2%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= numpage - 1%>" onclick="NewTable(this.name, this.lang)"><%= numpage - 1%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= numpage%>" onclick="NewTable(this.name, this.lang)"><%= numpage%></a>
                <%                  }
                                                    if (c == item && item != 1) {
                                                        if (item < (numpage / 2)) {%>
                <a href="#" lang="<%=msgright%>"   name="<%= item - 1%>" onclick="NewTable(this.name, this.lang)"><%= item - 1%></a>
                <a href="#" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="NewTable(this.name, this.lang)"><%= item%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item + 1%>" onclick="NewTable(this.name, this.lang)"><%= item + 1%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item + 2%>" onclick="NewTable(this.name, this.lang)"><%= item + 2%></a>

                ...
                <a href="#" lang="<%=msgright%>"   name="<%= numpage - 3%>" onclick="NewTable(this.name, this.lang)"><%= numpage - 3%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= numpage - 2%>" onclick="NewTable(this.name, this.lang)"><%= numpage - 2%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= numpage - 1%>" onclick="NewTable(this.name, this.lang)"><%= numpage - 1%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= numpage%>" onclick="NewTable(this.name, this.lang)"><%= numpage%></a>
                <%                }%>
                <%                  if (item >= (numpage / 2) && item != numpage) {
                                                            int start = 1;
                %>
                <a href="#" lang="<%=msgright%>"   name="<%= start%>" onclick="NewTable(this.name, this.lang)"><%= start%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= start + 1%>" onclick="NewTable(this.name, this.lang)"><%= start + 1%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= start + 2%>" onclick="NewTable(this.name, this.lang)"><%= start + 2%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= start + 3%>" onclick="NewTable(this.name, this.lang)"><%= start + 3%></a>
                ...
                <a href="#" lang="<%=msgright%>"   name="<%= item - 2%>" onclick="NewTable(this.name, this.lang)"><%= item - 2%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item - 1%>" onclick="NewTable(this.name, this.lang)"><%= item - 1%></a>
                <a href="#" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="NewTable(this.name, this.lang)"><%= item%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item + 1%>" onclick="NewTable(this.name, this.lang)"><%= item + 1%></a>
                <%                }
                %>
                <%                    if (item >= (numpage / 2) && item == numpage) {
                                                            int start = 1;
                %>
                <a href="#" lang="<%=msgright%>"   name="<%= start%>" onclick="NewTable(this.name, this.lang)"><%= start%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= start + 1%>" onclick="NewTable(this.name, this.lang)"><%= start + 1%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= start + 2%>" onclick="NewTable(this.name, this.lang)"><%= start + 2%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= start + 3%>" onclick="NewTable(this.name, this.lang)"><%= start + 3%></a>
                ...
                <a href="#" lang="<%=msgright%>"   name="<%= item - 3%>" onclick="NewTable(this.name, this.lang)"><%= item - 3%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item - 2%>" onclick="NewTable(this.name, this.lang)"><%= item - 2%></a>
                <a href="#" lang="<%=msgright%>"   name="<%= item - 1%>" onclick="NewTable(this.name, this.lang)"><%= item - 1%></a>
                <a href="#" lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="NewTable(this.name, this.lang)"><%= item%></a>

                <%                }
                %>
                <%            }
                                  }
                              }
                %>
                <%
                              if (item + 1 <= numpage) {
                                  trang = item + 1;
                              } else {
                                  trang = item;
                              }
                %>
                <a href="#" lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="NewTable(this.name, this.lang)">»</a>
                <%  }
                %>
            </div>
        </form>
    </div>
</div>
<div id="Map" style=" width: 49%; overflow: hidden; ">
<%
            if (v.size() > 0) {%>
<div class="bloc">
    <div class="seat">
        <%
                for (int i = (item1 - 1) * 30; i < (item1 - 1) * 30 + 30 && i < vsize1; i++) {
                    Beans.Ban b = (Beans.Ban) v.elementAt(i);
        %>
        <%
        if (b.getMaTTBan() == 1) {%>
        <a href="#" class="available" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" lang="<%=msgright%>" onclick="DetailTable(this.name, this.lang)"><center><%=b.getTenBan()%></center></a>
        <%  } else if (b.getMaTTBan() == 2) {%>
        <a href="#" class="notbill" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" lang="<%=msgright%>" onclick="DetailTable(this.name, this.lang)"><center><%=b.getTenBan()%></center></a>
        <%  } else if (b.getMaTTBan() == 3) {%>
        <a href="#" class="inbill" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" lang="<%=msgright%>" onclick="DetailTable(this.name, this.lang)"><center><%=b.getTenBan()%></center></a>
        <%  } else if (b.getMaTTBan() == 4) {%>
        <a href="#" class="num paid" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" lang="<%=msgright%>" onclick="DetailTable(this.name, this.lang)"><center><%=b.getTenBan()%></center></a>
        <%  } else if (b.getMaTTBan() == 5) {%>
        <a href="#" class="num cleanup" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" lang="<%=msgright%>" onclick="DetailTable(this.name, this.lang)"><center><%=b.getTenBan()%></center></a>
        <%  } else if (b.getMaTTBan() == 6) {%>
        <a href="#" class="num join" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" lang="<%=msgright%>" onclick="DetailTable(this.name, this.lang)"><center><%=b.getTenBan()%></center></a>
        <%  } else if (b.getMaTTBan() == 7) {%>
        <a href="#" class="num booked" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" lang="<%=msgright%>" onclick="DetailTable(this.name, this.lang)"><center><%=b.getTenBan()%></center></a>
        <%  } else {%>
        <a href="#" class="num check" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" lang="<%=msgright%>" onclick="DetailTable(this.name, this.lang)"><center><%=b.getTenBan()%></center></a>
        <%  }
        %>


        <%  }
        %>
        <div class="pagination" style=" margin-bottom: 0; margin-top: 0;">
            <%
                    int trang1 = 1;
                    if (item1 > 1) {
                        trang1 = item1 - 1;
                    }
            %>
            <%
        if (vsize1 > 30) {%>
            <a href="#" class="prev" name="<%=makv%>"  title="<%= trang%>" lang="<%=msgright%>" onclick="ShowMap(this.name, this.title, this.lang)">«</a>
            <%
                            for (int c = 1; c <= numpage1; c++) {

                                if (c != item1) {
            %> <a href="#" name="<%= makv%>" title="<%= c%>" lang="<%=msgright%>" onclick="ShowMap(this.name, this.title, this.lang)" ><%= c%></a>
            <% } else {%><a class="current"> <%= c%></a> <% }

                            }
            %>
            <%
                            if (item + 1 <= numpage1) {
                                trang1 = item1 + 1;
                            } else {
                                trang1 = item1;
                            }
            %>
            <a href="#" class="next" name="<%= makv%>" title="<%= trang%>" lang="<%=msgright%>" onclick="ShowMap(this.name, this.title, this.lang)">»</a>

            <%  }
            %>
        </div>
    </div>
</div>
<%  }
%>
</div>
<div id="DetailTable" style=" width: 49%; margin-top: 20px;" class="bloc" >
</div>


